﻿using RH.USER.DAL.Repository;
using RH.USER.MODEL.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RH.USER.BLL.Service
{
    public class UserService : IUserService
    {

        private readonly IUserRepository _IUserRepository;

        public UserService(IUserRepository userRepository)
        {

            _IUserRepository = userRepository;
        }
        public async Task<bool> GetAsyncUserInfo(string UserName, string UserPassword)
        {
            var user = await _IUserRepository.GetAsyncUserInfo(UserName);
            if (user == null)
            {
                return false; // 用户不存在
            }

            // 比较密码，假设密码已加密存储
            return user.UserPassword == UserPassword; // 实际中应使用加密和哈希

        }

        public async Task AddUser(User user)
        {
            await _IUserRepository.AddUser(user);
        }

        public async Task<string> GetUserPasswordAsync(string userName)
        {
            return await _IUserRepository.GetUserPasswordAsync(userName);
        }
    }
}
